Interface Extension Method, Apparatus, and System

ABSTRACT

A gateway device receives interface information sent by an interface extension device, where an Ethernet interface of the interface extension device is connected to a target Ethernet interface of the gateway device, and the interface information includes an interface type and a media access control (MAC) address of a first non-Ethernet interface of the interface extension device. The gateway device creates a first virtual interface on the target Ethernet interface based on the interface information, where the first virtual interface corresponds to the first non-Ethernet interface, and an interface type of the first virtual interface is an Ethernet interface. The gateway device sends an interface creation success notification to the interface extension device. The gateway device may obtain data of the first non-Ethernet interface through the first virtual interface, thereby implementing interface extension of the gateway device.

CROSS-REFERENCE TO RELATED APPLICATIONS

This is a continuation of International Patent Application No.PCT/CN2020/115785 filed on Sep. 17, 2020, which claims priority toChinese Patent Application No. 201910878294.0 filed on Sep. 17, 2019.The disclosures of the aforementioned applications are herebyincorporated by reference in their entireties.

TECHNICAL FIELD

This application relates to the field of communication technologies, andin particular, to an interface extension method, apparatus, and system.

BACKGROUND

The rapid development of network technologies enables informationexchange and communication to be extended from people to people tothings to things, and therefore a concept of Internet of things (IoT)emerges. Currently, an architecture of the IoT may be divided into aperception layer, a network layer, and an application layer. The sensinglayer is where objects are identified and information is collected. Thenetwork layer is where information obtained at the perception layer istransferred and processed. The application layer is a layer at whichusers interact with the IoT, and is used to implement intelligentapplication of the IoT.

In the architecture of the IoT, a perception layer network and a networklayer network (namely, a communication network) need to be connectedthrough a gateway device. The gateway device generally includes one ormore types of network interfaces, and each type of the networkinterfaces is connected to a perception layer network. For example, agateway device with a power line communication (PLC) interface mayimplement interconnection between a PLC network and the communicationnetwork, and a gateway device with a radio frequency (RF) interface mayimplement interconnection between an RF network and the communicationnetwork.

However, because a network interface on each gateway device is fixed,different gateway devices need to be used for different perception layernetworks to implement interconnection with the communication network.Consequently, the gateway device has poor generality.

SUMMARY

This application provides an interface extension method, apparatus, andsystem, to resolve a current problem of poor generality of a gatewaydevice.

According to a first aspect, an interface extension method is provided.The method includes the following steps:

A gateway device receives interface information sent by an interfaceextension device, where an Ethernet interface of the interface extensiondevice is connected to a target Ethernet interface of the gatewaydevice, and the interface information includes an interface type and amedia access control (MAC) address of a first non-Ethernet interface ofthe interface extension device; the gateway device creates a firstvirtual interface on the target Ethernet interface based on theinterface information, where the first virtual interface corresponds tothe first non-Ethernet interface, and an interface type of the firstvirtual interface is an Ethernet interface; and the gateway device sendsan interface creation success notification to the interface extensiondevice.

Optionally, the first non-Ethernet interface may be any non-Ethernetinterface on the interface extension device, or the first non-Ethernetinterface may be a non-Ethernet interface of the interface extensiondevice connected to a perception layer network.

In this application, the target Ethernet interface of the gateway deviceis connected to the Ethernet interface of the interface extensiondevice, so that the gateway device creates, on the target Ethernetinterface, the first virtual interface corresponding to the firstnon-Ethernet interface of the interface extension device. The gatewaydevice may obtain data of the first non-Ethernet interface on theinterface extension device through the first virtual interface, that is,the first non-Ethernet interface on the interface extension device isequivalent to a remote physical interface of the first virtual interfaceon the gateway device. This implements interface extension of thegateway device, so that the gateway device can be connected to theperception layer network through the non-Ethernet interface on theinterface extension device. In other words, the gateway device can beconnected to different perception layer networks through the interfaceextension device provided that the gateway device includes an Ethernetinterface. The gateway device has good generality.

Optionally, that the first virtual interface corresponds to the firstnon-Ethernet interface includes: A MAC address of the first virtualinterface is the same as the MAC address of the first non-Ethernetinterface.

In this application, because the MAC address of the first virtualinterface is the same as the MAC address of the first non-Ethernetinterface, data arriving at the first non-Ethernet interface on theinterface extension device can arrive at the first virtual interface ofthe gateway device. In other words, the first non-Ethernet interface onthe interface extension device is equivalent to the remote physicalinterface of the first virtual interface on the gateway device.

Optionally, the interface information further includes an interface typeand a MAC address of a second non-Ethernet interface of the interfaceextension device. The gateway device creates, on the target Ethernetinterface, a second virtual interface corresponding to the secondnon-Ethernet interface. An interface type of the second virtualinterface is an Ethernet interface.

Optionally, after the gateway device creates the first virtual interfaceon the target Ethernet interface based on the interface information, thegateway device assigns an Internet Protocol (IP) address to the firstvirtual interface. The gateway device adds a routing entry correspondingto the first virtual interface to a routing table of the gateway device.

Optionally, after the gateway device sends the interface creationsuccess notification to the interface extension device, the gatewaydevice receives a network access notification sent by the interfaceextension device, where the network access notification includes anidentifier of a to-be-joined network node. The to-be-joined network nodeis a network node that completes layer-2 networking with the interfaceextension device through the first non-Ethernet interface. The gatewaydevice sends an IP address assignment notification to the to-be-joinednetwork node through the interface extension device, where the IPaddress assignment notification includes an IP address of theto-be-joined network node. The IP address of the to-be-joined networknode and the IP address of the first virtual interface belong to a samenetwork segment. A source MAC address of the IP address assignmentnotification is the MAC address of the first virtual interface. Adestination MAC address of the IP address assignment notification is aMAC address of the to-be-joined network node. The MAC address of thefirst virtual interface is the same as the MAC address of the firstnon-Ethernet interface.

Optionally, the network access notification includes an identifier ofthe first non-Ethernet interface. The identifier may be specifically theMAC address of the first non-Ethernet interface. For example, a sourceMAC address of the network access notification may be the MAC address ofthe first non-Ethernet interface. The network access notification mayinclude one or more identifiers of one or more to-be-joined networknodes, and the one or more identifiers of the one or more to-be-joinednetwork nodes may be carried in a data field of a payload of an Ethernetframe.

In this application, the IP address of the to-be-joined network node andthe IP address of the first virtual interface belong to a same networksegment. In other words, a network address in the IP address assigned bythe gateway device to the to-be-joined network node is the same as theIP address of the first virtual interface. The first virtual interfaceis a virtual interface used by the gateway device to perform layer-3network communication with the to-be-joined network node.

Optionally, the identifier of the to-be-joined network node includes theMAC address of the to-be-joined network node. After the gateway devicesends the IP address assignment notification to the to-be-joined networknode through the interface extension device, the gateway device adds aneighbor entry corresponding to the to-be-joined network node to aneighbor table of the gateway device.

Optionally, an Ethernet frame is used for information transmissionbetween the gateway device and the interface extension device. TheEthernet frame includes a target indication field. The target indicationfield is used to indicate a packet type of the Ethernet frame. Thepacket type includes a management packet or a data packet. A destinationdevice of the management packet is the gateway device or the interfaceextension device. A destination device of the data packet is neither thegateway device nor the interface extension device.

Optionally, the target indication field is further used to indicate avirtual interface of the gateway device for transmission of the Ethernetframe.

Optionally, the target indication field includes a first indicationfield and a second indication field. The first indication field is usedto indicate the packet type of the Ethernet frame. The second indicationfield is used to indicate a virtual interface of the gateway device fortransmission of the Ethernet frame.

Optionally, the target indication field is a tag protocol identifierfield.

Optionally, the Ethernet frame further includes a tag controlinformation (TCI) field. When the packet type of the Ethernet frame isthe management packet, the TCI field is used to indicate a packet lengthof the Ethernet frame. When the packet type of the Ethernet frame is thedata packet, the TCI field is used to indicate a priority of theEthernet frame.

Optionally, after the gateway device sends the interface creationsuccess notification to the interface extension device, the gatewaydevice sends an interface parameter to the interface extension device,where the interface parameter includes a channel and/or transmit powerof the first non-Ethernet interface. The gateway device may generate acorresponding interface parameter based on the interface type of thefirst non-Ethernet interface.

According to a second aspect, an interface extension method is provided.The method includes the following steps:

An interface extension device sends interface information to a gatewaydevice, where an Ethernet interface of the interface extension device isconnected to a target Ethernet interface of the gateway device, theinterface information includes an interface type and a MAC address of afirst non-Ethernet interface of the interface extension device, so thatthe gateway device creates, on the target Ethernet interface based onthe interface information, a first virtual interface corresponding tothe first non-Ethernet interface, and an interface type of the firstvirtual interface is an Ethernet interface; and the interface extensiondevice receives an interface creation success notification sent by thegateway device, where the interface creation success notification isused to indicate the interface extension device that the gateway devicehas completed creation of a virtual interface corresponding to anon-Ethernet interface in the interface information.

Optionally, that the first virtual interface corresponds to the firstnon-Ethernet interface includes: A MAC address of the first virtualinterface is the same as the MAC address of the first non-Ethernetinterface.

Optionally, the interface information further includes an interface typeand a MAC address of a second non-Ethernet interface of the interfaceextension device, so that the gateway device creates, on the targetEthernet interface, a second virtual interface corresponding to thesecond non-Ethernet interface. An interface type of the second virtualinterface is an Ethernet interface.

Optionally, after the interface extension device receives the interfacecreation success notification sent by the gateway device, and theinterface extension device completes layer-2 networking with ato-be-joined network node through the first non-Ethernet interface, theinterface extension device generates a network access notification, andsends the network access notification to the gateway device. The networkaccess notification includes an identifier of the to-be-joined networknode. The interface extension device receives an IP address assignmentnotification that is sent by the gateway device to the to-be-joinednetwork node, converts a frame type of the IP address assignmentnotification into a target frame type, sends an IP address assignmentnotification whose frame type is the target frame type to theto-be-joined network node through the first non-Ethernet interface,where the IP address assignment notification includes an IP address ofthe to-be-joined network node. The target frame type is a frame typesupported by a network to which the to-be-joined network node belongs.The IP address of the to-be-joined network node and an IP address of thefirst virtual interface belong to a same network segment. A source MACaddress of the IP address assignment notification is the MAC address ofthe first virtual interface. A destination MAC address of the IP addressassignment notification is a MAC address of the to-be-joined networknode. The MAC address of the first virtual interface is the same as theMAC address of the first non-Ethernet interface.

Optionally, the network access notification includes an identifier ofthe first non-Ethernet interface. The identifier may be specifically theMAC address of the first non-Ethernet interface. For example, a sourceMAC address of the network access notification may be the MAC address ofthe first non-Ethernet interface. The network access notification mayinclude identifiers of one or more to-be-joined network nodes, and theidentifiers of the one or more to-be-joined network nodes may be carriedin a data field of a payload of an Ethernet frame.

In this application, the interface extension device implementsconversion between an Ethernet frame type and the target frame type,that is, implements layer-2 protocol conversion. Therefore, a layer-2protocol conversion module does not need to be disposed in the gatewaydevice, so that resource consumption of the gateway device can bereduced.

Optionally, an Ethernet frame is used for information transmissionbetween the gateway device and the interface extension device. TheEthernet frame includes a target indication field. The target indicationfield is used to indicate a packet type of the Ethernet frame. Thepacket type includes a management packet or a data packet. A destinationdevice of the management packet is the gateway device or the interfaceextension device. A destination device of the data packet is neither thegateway device nor the interface extension device.

Optionally, the target indication field is further used to indicate avirtual interface of the gateway device for transmission of the Ethernetframe.

Optionally, the target indication field includes a first indicationfield and a second indication field. The first indication field is usedto indicate the packet type of the Ethernet frame. The second indicationfield is used to indicate a virtual interface of the gateway device fortransmission of the Ethernet frame.

Optionally, the target indication field is a tag protocol identifierfield.

Optionally, the Ethernet frame further includes a TCI field. When thepacket type of the Ethernet frame is the management packet, the TCIfield is used to indicate a packet length of the Ethernet frame. Whenthe packet type of the Ethernet frame is the data packet, the TCI fieldis used to indicate a priority of the Ethernet frame.

According to a third aspect, an interface extension apparatus isprovided, and is used in a gateway device. The apparatus includes aplurality of functional modules, and the plurality of functional modulesinteract with each other to implement the method according to the firstaspect and the implementations of the first aspect. The plurality offunctional modules may be implemented based on software, hardware, or acombination of software and hardware, and the plurality of functionalmodules may be randomly combined or divided depending on specificimplementation.

According to a fourth aspect, an interface extension apparatus isprovided, and is used in an interface extension device. The apparatusincludes a plurality of functional modules, and the plurality offunctional modules interact with each other to implement the methodaccording to the second aspect and the implementations of the secondaspect. The plurality of functional modules may be implemented based onsoftware, hardware, or a combination of software and hardware, and theplurality of functional modules may be randomly combined or divideddepending on specific implementation.

According to a fifth aspect, a gateway device is provided, where thegateway device includes a processor and a memory.

The memory is configured to store a computer program, where the computerprogram includes program instructions.

The processor is configured to invoke the computer program to implementthe interface extension method according to any one of the first aspector the implementations of the first aspect.

According to a sixth aspect, an interface extension device is provided,where the interface extension device includes a processor and a memory.

The memory is configured to store a computer program, where the computerprogram includes program instructions.

The processor is configured to invoke the computer program to implementthe interface extension method according to any one of the second aspector the implementations of the second aspect.

According to a seventh aspect, an interface extension system isprovided, where the interface extension system includes a gateway deviceand an interface extension device. An Ethernet interface of the gatewaydevice is connected to an Ethernet interface of the interface extensiondevice.

The gateway device includes the interface extension apparatus accordingto any one of the third aspect or the implementations of the thirdaspect, and the interface extension device includes the interfaceextension apparatus according to any one of the fourth aspect or theimplementations of the fourth aspect.

According to an eighth aspect, a computer storage medium is provided,where the computer storage medium stores instructions. When theinstructions are executed by a processor of a gateway device, theinterface extension method according to any one of the first aspect orthe implementations of the first aspect is implemented.

According to a ninth aspect, a computer storage medium is provided,where the computer storage medium stores instructions. When theinstructions are executed by a processor of an interface extensiondevice, the interface extension method according to any one of thesecond aspect or the implementations of the second aspect isimplemented.

According to a tenth aspect, a chip is provided, where the chip includesa programmable logic circuit and/or program instructions. When the chipruns, the interface extension method according to any one of the firstaspect or the implementations of the first aspect is implemented. Thechip may be a chip of an Ethernet adapter.

According to an eleventh aspect, a chip is provided, where the chipincludes a programmable logic circuit and/or program instructions. Whenthe chip runs, the interface extension method according to any one ofthe second aspect or the implementations of the second aspect isimplemented. The chip includes a chip of an Ethernet adapter, andfurther includes a non-Ethernet chip, for example, a PLC chip.

The technical solutions provided in this application bring at least thefollowing beneficial effects:

The target Ethernet interface of the gateway device is connected to theEthernet interface of the interface extension device, and the gatewaydevice creates, on the target Ethernet interface, the first virtualinterface corresponding to the first non-Ethernet interface of theinterface extension device. Because the MAC address of the first virtualinterface is the same as the MAC address of the first non-Ethernetinterface, data arriving at the first non-Ethernet interface on theinterface extension device can arrive at the first virtual interface ofthe gateway device. In other words, the first non-Ethernet interface onthe interface extension device is equivalent to a remote physicalinterface of the first virtual interface on the gateway device. Thisimplements interface extension of the gateway device, so that thegateway device can be connected to the perception layer network throughthe non-Ethernet interface on the interface extension device. In otherwords, the gateway device can be connected to different perception layernetworks through the interface extension device provided that thegateway device includes an Ethernet interface. The gateway device hasgood generality. In addition, the interface extension device implementslayer-2 protocol conversion between Ethernet and the perception layernetwork, and the gateway device implements the layer-3 forwardingfunction, so that heterogeneous perception layer networks cancommunicate with each other. In addition, the gateway device and theinterface extension device may be separately deployed, so that theinterface extension device can be remotely deployed. Therefore,flexibility of device deployment is high.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a schematic diagram depicting a structure of an interfaceextension system according to an embodiment of this application;

FIG. 2 is a schematic diagram of an application scenario related to aninterface extension system according to an embodiment of thisapplication;

FIG. 3 is a flowchart of an interface extension method according to anembodiment of this application;

FIG. 4 is a schematic diagram depicting a structure of an Ethernet frameaccording to an embodiment of this application;

FIG. 5 is a schematic diagram depicting a structure of an interfaceextension apparatus according to an embodiment of this application;

FIG. 6 is a schematic diagram depicting a structure of another interfaceextension apparatus according to an embodiment of this application;

FIG. 7 is a schematic diagram depicting a structure of still anotherinterface extension apparatus according to an embodiment of thisapplication;

FIG. 8 is a schematic diagram depicting a structure of yet anotherinterface extension apparatus according to an embodiment of thisapplication;

FIG. 9 is a schematic diagram depicting a structure of an interfaceextension apparatus according to another embodiment of this application;

FIG. 10 is a schematic diagram depicting a structure of anotherinterface extension apparatus according to another embodiment of thisapplication;

FIG. 11 is a block diagram of a gateway device according to anembodiment of this application; and

FIG. 12 is a block diagram of an interface extension device according toan embodiment of this application.

DESCRIPTION OF EMBODIMENTS

To make objectives, technical solutions, and advantages of thisapplication clearer, the following further describes implementations ofthis application in detail with reference to accompanying drawings.

FIG. 1 is a schematic diagram depicting a structure of an interfaceextension system according to an embodiment of this application. Asshown in FIG. 1, the interface extension system includes a gatewaydevice 101 and interface extension devices 102 a and 102 b (collectivelyreferred to as interface extension devices 102). A quantity of interfaceextension devices shown in FIG. 1 is merely an example, and does notconstitute any limitation on the interface extension system provided inthis embodiment of this application. For example, the gateway device 101may be connected to one interface extension device 102. Alternatively,the gateway device 101 may be connected to three, four, or moreinterface extension devices 102.

The gateway device 101 includes an Ethernet interface, and the interfaceextension device 102 includes an Ethernet interface and a non-Ethernetinterface. Optionally, there may be one or more Ethernet interfaces onthe gateway device 101. There may be one or more Ethernet interfaces onthe interface extension device 102. There may also be one or morenon-Ethernet interfaces on the interface extension device 102. Forexample, refer to FIG. 1. There are at least two Ethernet interfaces onthe gateway device 101. One of the Ethernet interfaces on the gatewaydevice 101 is connected to an Ethernet interface of the interfaceextension device 102 a, and the other of the Ethernet interfaces on thegateway device 101 is connected to an Ethernet interface of theinterface extension device 102 b. Certainly, there may also be one ormore non-Ethernet interfaces on the gateway device 101. This is notlimited in this embodiment of this application.

Optionally, a non-Ethernet interface on the interface extension devicemay include a network interface and/or an operation technology (OT)interface. The network interface includes a PLC interface, an RFinterface, a ZIGBEE interface, a BLUETOOTH interface, and the like. TheOT interface includes an RS232 interface, an RS485 interface, acontroller area network (CAN) interface, and the like.

For example, FIG. 2 is a schematic diagram of an application scenariorelated to an interface extension system according to an embodiment ofthis application. In the application scenario shown in FIG. 2, assumingthat an interface extension device 102 a includes a PLC interface, andan interface extension device 102 b includes an RF interface, a gatewaydevice 101 may be connected to a PLC network through the interfaceextension device 102 a, and connected to an RF network through theinterface extension device 102 b. Refer to FIG. 2. Perception layerdevices 103 a 1 to 103 a 3 are connected to the interface extensiondevice 102 a through the PLC network, and perception layer devices 103 b1 to 103 b 3 are connected to the interface extension device 102 bthrough the RF network. The PLC network and the RF network each includenetwork nodes. A quantity of network nodes in a perception layer networkmatches a quantity of connected perception layer devices, that is, thenetwork nodes are connected to the perception layer devices in aone-to-one correspondence. The perception layer devices 103 a 1 to 103 a3 are connected to the interface extension device 102 a through the PLCnetwork, that is, the perception layer devices 103 a 1 to 103 a 3 eachare connected to the interface extension device 102 a through a networknode in the PLC network. The perception layer devices 103 b 1 to 103 b 3are connected to the interface extension device 102 b through the RFnetwork, that is, the perception layer devices 103 b 1 to 103 b 3 eachare connected to the interface extension device 102 b through a networknode in the RF network. The PLC network and the RF network each may be amesh network, and the mesh network features multi-hop interconnectionand a mesh topology. Refer to FIG. 2. The perception layer devices 103 a1 to 103 a 3 may be smart meters, and the perception layer devices 103 b1 to 103 b 3 may be smart lamps. A network node in the perception layernetwork may be a standalone device, or may be integrated into aperception layer device as a functional module. This is not limited inthis embodiment of this application.

In the application scenario shown in FIG. 2, when the perception layerdevice generates running data information, the perception layer devicetransmits the running data information to a corresponding network nodein the perception layer network. The network node sends the running datainformation to a gateway device through the interface extension device.The gateway device sends the running data information to a correspondingremote monitoring device in an external network or a network node inanother perception layer network.

In this embodiment of this application, the gateway device is connectedto an Ethernet interface of the interface extension device through anEthernet interface, and virtualizes, on the Ethernet interface, avirtual interface corresponding to a non-Ethernet interface of theinterface extension device. This implements interface extension of thegateway device, so that the gateway device can be connected to theperception layer network through the non-Ethernet interface on theinterface extension device. In other words, the gateway device can beconnected to different perception layer networks through the interfaceextension device provided that the gateway device includes an Ethernetinterface. The gateway device has good generality. In addition, thegateway device and the interface extension device may be separatelydeployed, so that the interface extension unit can be remotely deployed.Therefore, flexibility of device deployment is high.

FIG. 3 is a flowchart of an interface extension method according to anembodiment of this application. The method may be used in the interfaceextension system shown in FIG. 1. As shown in FIG. 3, the methodincludes the following steps.

Step 301: An interface extension device sends interface information to agateway device.

The interface extension device may be any interface extension device inthe interface extension system shown in FIG. 1. The interface extensiondevice includes an Ethernet interface and n non-Ethernet interfaces, andMAC addresses of the n non-Ethernet interfaces may be the same ordifferent. For example, MAC addresses of non-Ethernet interfaces ofdifferent interface types may be the same. n is a positive integer. TheEthernet interface of the interface extension device is connected to atarget Ethernet interface of the gateway device. The interfaceinformation includes an interface type and a MAC address of a firstnon-Ethernet interface of the interface extension device. The firstnon-Ethernet interface may be any non-Ethernet interface on theinterface extension device, or the first non-Ethernet interface may be anon-Ethernet interface of the interface extension device connected to aperception layer network.

Optionally, when a quantity n of non-Ethernet interfaces on theinterface extension device is greater than or equal to 2, in a firstpossible implementation, the interface information includes interfacetypes and corresponding MAC addresses of the n non-Ethernet interfaces.For example, if the interface extension device includes threenon-Ethernet interfaces 1 to 3, the interface information includes aninterface type (PLC) and a MAC address (MAC1) of the non-Ethernetinterface 1, an interface type (PLC) and a MAC address (MAC2) of thenon-Ethernet interface 2, and an interface type (RF) and a MAC address(MAC3) of the non-Ethernet interface 3. The interface information may beunderstood as a 2-tuple including an interface type and a MAC address.In a second implementation, the interface information includes only aninterface type and a corresponding MAC address of a non-Ethernetinterface connected to the perception layer network. When a non-Ethernetinterface on the interface extension device that is not connected to theperception layer network is subsequently connected to the perceptionlayer network, the interface extension device may send the interfaceinformation that includes the interface type and the MAC address of thenon-Ethernet interface to the gateway device.

In the second possible implementation, the gateway device does not needto perform interface extension based on the non-Ethernet interface onthe interface extension device that is not connected to the perceptionlayer network. This can save resources of the gateway device.

Optionally, the interface information may be carried in a data field ofa payload of an Ethernet frame for sending after being type-length-value(TLV)-encoded. Certainly, the interface information may alternatively beencoded in another encoding scheme and then carried in the data field ofthe payload of the Ethernet frame for sending. The encoding scheme isnot limited in this embodiment of this application.

Optionally, after the Ethernet interface of the interface extensiondevice is connected to the target Ethernet interface of the gatewaydevice, security authentication and key negotiation may be performedbetween the interface extension device and the gateway device.Optionally, the security authentication and the key negotiation may beperformed between the interface extension device and the gateway deviceaccording to a Transport Layer Security (TLS) protocol. After thesecurity authentication and the key negotiation are completed betweenthe interface extension device and the gateway device, data istransmitted between the interface extension device and the gatewaydevice in an encryption mode. Step 301 is implemented as follows: Theinterface extension device encrypts the interface information, and sendsthe encrypted interface information to the gateway device.

Step 302: The gateway device creates, on the target Ethernet interfacebased on the interface information, a first virtual interfacecorresponding to the first non-Ethernet interface.

An interface type of the first virtual interface is an Ethernetinterface. That the first virtual interface corresponds to the firstnon-Ethernet interface includes: A MAC address of the first virtualinterface is the same as the MAC address of the first non-Ethernetinterface. The gateway device may implement layer-3 data forwardingthrough the first virtual interface. The gateway device may store acorrespondence between the interface type of the first virtual interfaceand the interface type of the first non-Ethernet interface.

Optionally, the interface information further includes an interface typeand a MAC address of a second non-Ethernet interface of the interfaceextension device. The gateway device creates, on the target Ethernetinterface based on the interface information, a second virtual interfacecorresponding to the second non-Ethernet interface. An interface type ofthe second virtual interface is also an Ethernet interface. A MACaddress of the second virtual interface is the same as the MAC addressof the second non-Ethernet interface.

For example, if the first non-Ethernet interface is a PLC interface, thefirst virtual interface is a virtual interface corresponding to the PLCinterface. If the first non-Ethernet interface is an RF interface, thefirst virtual interface is a virtual interface corresponding to the RFinterface. If the first non-Ethernet interface is a ZIGBEE interface,the first virtual interface is a virtual interface corresponding to theZIGBEE interface.

Step 303: The gateway device assigns an IP address to the first virtualinterface.

An IP address generally includes two parts: a network identifier numberand a host identifier number. Therefore, the IP address may include twoparts: a network address and a host address. The two parts are usuallydistinguished between each other by using a subnet mask. Optionally, theIP address assigned by the gateway device to the virtual interface maybe an Internet Protocol version 4 (IPv4) address, an Internet Protocolversion 6 (IPv6) address, or any further IP address. This is not limitedin this embodiment of this application. A virtual interface functions asa gateway of the lower perception layer network. The IP address assignedby the gateway device to the virtual interface is a network address,which is also referred to as a subnet address or a network segmentaddress.

For example, an IP address assigned by the gateway device to the virtualinterface corresponding to the PLC interface is 2001::/64, an IP addressassigned by the gateway device to the virtual interface corresponding tothe RF interface is 2002::/64, and an IP address assigned by the gatewaydevice to the virtual interface corresponding to the ZIGBEE interface is2003::/64.

Step 304: The gateway device adds a routing entry corresponding to thefirst virtual interface to a routing table of the gateway device.

For example, the routing table of the gateway device is shown in Table1.

TABLE 1 Index Destination Next hop (Index) IP address (next hop) Port 12001::/64 On link PLC virtual interface 2 2002::/64 On link RF virtualinterface 3 2003::/64 On link ZIGBEE virtual interface

A value in the “port” column in Table 1 is specifically an interfaceidentifier. For ease of understanding, the PLC/RF/ZIGBEE virtualinterface is used as an interface identifier to represent a specificinterface in this application. Table 1 includes three routing entries.The three routing entries respectively indicate that an outboundinterface destined for a network address or subnet 2001::/64 is a PLCvirtual interface, an outbound interface destined for a network addressor subnet 2002::/64 is an RF virtual interface, and an outboundinterface destined for a network address or subnet 2003::/64 is a ZIGBEEvirtual interface. To be specific, when receiving a packet whose networkaddress in a destination IP address is 2001::/64 (that is, thedestination IP address is in an address segment 2001::/64), the gatewaydevice may learn, by querying the routing table shown in Table 1, that anext-hop port is the PLC virtual interface. In this case, the gatewaydevice forwards the packet through the PLC virtual interface. Whenreceiving a packet whose network address in a destination IP address is2002::/64, the gateway device may learn, by querying the routing tableshown in Table 1, that a next-hop port is the RF virtual interface. Inthis case, the gateway device forwards the packet through the RF virtualinterface. When receiving a packet whose network address in adestination IP address is 2003::/64, the gateway device may learn, byquerying the routing table shown in Table 1, that the next-hop port isthe ZIGBEE virtual interface. In this case, the gateway device forwardsthe packet through the ZIGBEE virtual interface. “On link” indicates adirect connection. Assuming that the first virtual interface is thevirtual interface corresponding to the PLC interface, referring to theexample in step 303, an IP address assigned to the first virtualinterface is 2001::/64. In this case, a routing entry whose index is 1in Table 1 is a routing entry corresponding to the first virtualinterface.

Step 305: The gateway device sends an interface creation successnotification to the interface extension device.

Optionally, after creating the first virtual interface on the targetEthernet interface, the gateway device sends the interface creationsuccess notification to the interface extension device. The interfacecreation success notification is used to indicate the interfaceextension device that the gateway device has completed creation of avirtual interface corresponding to a non-Ethernet interface in theinterface information. Optionally, step 305 may be performed before step303 and step 304, or step 305 may be performed simultaneously with step303 and step 304. This is not limited in this embodiment of thisapplication.

Step 306: The interface extension device determines that the gatewaydevice has completed interface extension.

The interface extension device determines that the gateway device hascompleted the interface extension, that is, the interface extensiondevice determines that the gateway device can perform layer-3 dataforwarding. In this case, the interface extension device may send anetwork access notification of a to-be-joined network node to thegateway device, to complete layer-3 networking between the to-be-joinednetwork node and the gateway device.

In this embodiment of this application, the target Ethernet interface ofthe gateway device is connected to the Ethernet interface of theinterface extension device, so that the gateway device creates, on thetarget Ethernet interface, the first virtual interface corresponding tothe first non-Ethernet interface of the interface extension device.Because the MAC address of the first virtual interface is the same asthe MAC address of the first non-Ethernet interface, data arriving atthe first non-Ethernet interface on the interface extension device canarrive at the first virtual interface of the gateway device. In otherwords, the first non-Ethernet interface on the interface extensiondevice is equivalent to a remote physical interface of the first virtualinterface on the gateway device. This implements interface extension ofthe gateway device, so that the gateway device can be connected to theperception layer network through the non-Ethernet interface on theinterface extension device. In other words, the gateway device can beconnected to different perception layer networks through the interfaceextension device provided that the gateway device includes an Ethernetinterface. The gateway device has good generality.

Step 307: The gateway device sends an interface parameter to theinterface extension device.

Optionally, after the gateway device sends the interface creationsuccess notification to the interface extension device, the gatewaydevice may further send the interface parameter to the interfaceextension device, where the interface parameter includes a channeland/or transmit power of the first non-Ethernet interface on theinterface extension device.

Optionally, the gateway device may generate a corresponding interfaceparameter based on the interface type of the first non-Ethernetinterface. Different types of non-Ethernet interfaces may have differentinterface parameters. For example, for the PLC interface, the interfaceparameter may further include a whitelist of PLC network nodes. Thewhitelist of PLC network nodes is used to indicate PLC network nodesthat are allowed to access the gateway device through the interfaceextension device. For the RF interface and/or the ZIGBEE interface, theinterface parameter may further include a modulation scheme. Certainly,a default interface parameter may be configured on the interfaceextension device. Alternatively, the gateway device may not send theinterface parameter to the interface extension device, that is, step 307may not be performed. This is not limited in this embodiment of thisapplication.

Step 308: The interface extension device generates a network accessnotification after completing layer-2 networking with the to-be-joinednetwork node through the first non-Ethernet interface, where the networkaccess notification includes an identifier of the to-be-joined networknode.

The identifier of the to-be-joined network node may be a MAC address ofthe to-be-joined network node, another hardware address that canuniquely identify the to-be-joined network node, or the like. Thenetwork access notification further includes the MAC address of thefirst non-Ethernet interface, so that the gateway device assigns an IPaddress to the to-be-joined network node based on the IP address (anetwork segment address) of the first virtual interface corresponding tothe first non-Ethernet interface.

Optionally, the interface extension device may perform layer-2networking with the to-be-joined network node before or after receivingthe interface creation success notification sent by the gateway device.During layer-2 networking between the interface extension device and theto-be-joined network node, layer-2 network security authentication andkey negotiation may further be performed, to improve security of datatransmission between the interface extension device and the to-be-joinednetwork node.

Step 309: The interface extension device sends the network accessnotification to the gateway device.

The interface extension device sends the network access notification tothe gateway device only after receiving the interface creation successnotification sent by the gateway device, to complete the layer-3networking between the to-be-joined network node and the gateway device.

Step 310: The gateway device sends an IP address assignment notificationof the to-be-joined network node to the interface extension device,where the IP address assignment notification includes an IP address ofthe to-be-joined network node.

A source MAC address of the IP address assignment notification is theMAC address of the first virtual interface, and a destination MACaddress of the IP address assignment notification is a MAC address ofthe to-be-joined network node. The MAC address of the first virtualinterface is the MAC address of the first non-Ethernet interface. Afterreceiving the network access notification sent by the interfaceextension device, the gateway device may first perform layer-3 networksecurity authentication and key negotiation with the to-be-joinednetwork node. After performing the layer-3 network securityauthentication and the key negotiation with the to-be-joined networknode, the gateway device assigns the IP address to the to-be-joinednetwork node. During the layer-3 network security authentication and thekey negotiation between the to-be-joined network node and the gatewaydevice, data transmission may be implemented by using a link-localaddress. The link-local address is generated based on a MAC address.Optionally, the layer-3 network security authentication and the keynegotiation between the to-be-joined network node and the gateway devicemay be performed according to a TLS protocol. After the layer-3 networksecurity authentication and the key negotiation are completed betweenthe to-be-joined network node and the gateway device, data istransmitted between the to-be-joined network node and the gateway devicein an encryption mode. This can improve security of data transmissionbetween the gateway device and the to-be-joined network node.

A neighbor table of the gateway device may prestore a neighbor entrybased on the link-local address of the to-be-joined network node. Forexample, the neighbor table of the gateway device may be shown in Table2.

TABLE 2 Index IP address Port MAC Address 1 FE80::IID-MAC-B PLC virtualinterface MAC-B 2 FE80::IID-MAC-C RF virtual interface MAC-C

During the layer-3 network security authentication and the keynegotiation between the gateway device and the to-be-joined networknode, if an IP address carried in an authentication message that is sentby the to-be-joined network node to the gateway device isFE80::IID-MAC-B, it can be learned based on Table 2 that a virtualinterface used by the gateway device to communicate with theto-be-joined network node is the PLC virtual interface, and the MACaddress of the to-be-joined network node is MAC-B. The gateway deviceperforms MAC encapsulation on the IP address assignment notification byusing a MAC address of the PLC virtual interface as a source MAC addressand a MAC address MAC-B of the to-be-joined network node as adestination MAC address.

In this embodiment of this application, a network address in the IPaddress assigned by the gateway device to the to-be-joined network nodeis the same as the IP address of the first virtual interface of thegateway device. In other words, the IP address of the to-be-joinednetwork node and the IP address of the first virtual interface belong toa same network segment. For example, assuming that the to-be-joinednetwork node is a PLC network node, referring to the examples in step303 and step 304, the network address in the IP address assigned by thegateway device to the to-be-joined network node is 2001::/64.

Because an IP address of a network node in the perception layer networkand an IP address of a virtual interface on a corresponding gatewaydevice belong to a same network segment, when the gateway devicereceives a packet that needs to be forwarded to a target network node inthe perception layer network, the gateway device may parse an IP packetheader of the packet to obtain an IP address; determine, based on anetwork address in the IP address and the routing table shown in Table1, a virtual interface through which the packet is forwarded; andforward the packet to the target network node through the virtualinterface. In this way, precise routing is implemented.

Step 311: The gateway device adds a neighbor entry corresponding to theto-be-joined network node to the neighbor table of the gateway device.

Optionally, when the network access notification sent by the interfaceextension device to the gateway device includes the MAC address of theto-be-joined network node, the gateway device may generate, based on theMAC address and the IP address of the to-be-joined network node, theneighbor entry corresponding to the to-be-joined network node; and addthe neighbor entry to the neighbor table.

For example, based on Table 2, assuming that the IP address assigned bythe gateway device to the to-be-joined network node is 2002::IID-MAC-B,and the MAC address of the to-be-joined network node is MAC-B, theneighbor entry corresponding to the to-be-joined network node added tothe gateway device is an entry whose index is 3 shown in Table 3.

TABLE 3 Index IP address Port MAC Address 1 FE80::IID-MAC-B PLC virtualinterface MAC-B 2 FE80::IID-MAC-C RF virtual interface MAC-C 32001::IID-MAC-B PLC virtual interface MAC-B

Based on Table 3, when a destination IP address carried in a packetreceived by the gateway device is 2001::IID-MAC-B, the gateway devicemay use the MAC address of the PLC virtual interface as a source MACaddress, and use the MAC address of the to-be-joined network node as adestination MAC address, perform MAC layer encapsulation on the packet,and forward, through the PLC virtual interface, the packet on which theMAC layer encapsulation is performed to the to-be-joined network node.

Optionally, in IPv4, the neighbor table of the gateway device may be anAddress Resolution Protocol (ARP) table. In IPv6, the neighbor table ofthe gateway device is a protocol-defined neighbor table.

Step 312: The interface extension device converts a frame type of the IPaddress assignment notification into a target frame type, and sends anIP address assignment notification whose frame type is the target frametype to the to-be-joined network node through the first non-Ethernetinterface.

A frame type of the IP address assignment notification sent by thegateway device to the interface extension device is an Ethernet frame,and the target frame type is a frame type supported by a network towhich the to-be-joined network node belongs. For example, when theto-be-joined network node is a PLC network node, the target frame typeis a PLC MAC frame. When the to-be-joined network node is an RF networknode, the target frame type is an RF MAC frame.

In this embodiment of this application, the interface extension deviceimplements conversion between the Ethernet frame type and the targetframe type, that is, implements layer-2 protocol conversion. Therefore,a layer-2 protocol conversion module does not need to be disposed in agateway device, so that resource consumption of the gateway device canbe reduced.

The interface extension device also supports protocols corresponding tovarious types of non-Ethernet interfaces on the interface extensiondevice. For example, the interface extension device needs to supportframing of a PLC carrier signal, and modulation and demodulation aresupported at a MAC layer and a physical layer (PHY) of a PLC protocol.

Optionally, when an IPv6 address is used in this embodiment of thisapplication, the interface extension device may further implementconversion between an IPv6 header and a IPv6 over Low-Power WirelessPersonal Area Networks (6LowPAN) header. When forwarding a packet sentby the gateway device to a network node, the interface extension deviceconverts an IPv6 header into a 6LowPAN header, to compress a packetheader. In this way, less transmission resources are occupied.

Optionally, after receiving the IP address assignment notification, theto-be-joined network node may add the routing entry and the neighborentry that correspond to the gateway device, and set a next hop of adefault route to the gateway device, thereby implementing layer-3network communication between the to-be-joined network node and thegateway device. In this embodiment of this application, the interfaceextension device implements layer-2 protocol conversion between Ethernetand the perception layer network, and the gateway device implements thelayer-3 forwarding function, so that heterogeneous perception layernetworks can communicate with each other.

In this embodiment of this application, an Ethernet frame is used fordata transmission between the gateway device and the interface extensiondevice. The Ethernet frame includes a target indication field, and thetarget indication field is used to indicate a packet type of theEthernet frame. The packet type includes a management packet or a datapacket. A destination device of the management packet is the gatewaydevice or the interface extension device. A destination device of thedata packet is neither the gateway device nor the interface extensiondevice. Optionally, when the gateway device or the interface extensiondevice receives the management packet, the gateway device or theinterface extension device performs an operation indicated in a payloadfield of the management packet. When the gateway device or the interfaceextension device receives the data packet, the gateway device or theinterface extension device forwards the data packet to another device.The target indication field is located in an Ethernet frame header.

In this embodiment of this application, a destination device of theinterface information and the network access notification that are sentby the interface extension device to the gateway device is the gatewaydevice. A destination device of the interface creation successnotification and the interface parameter that are sent by the gatewaydevice to the interface extension device is the interface extensiondevice. Therefore, all these packets are management packets. In anEthernet frame obtained by performing MAC layer encapsulation on theinterface information, the interface creation success notification, theinterface parameter, and the network access notification, the targetindication field is used to indicate that a packet type of the Ethernetframe is a management packet. Both a destination MAC address and asource MAC address in the management packet each may be a fixed controladdress. For example, the destination MAC address may be 0180 C200 0001,and the source MAC address may be 0180 C200 0002. Alternatively, thedestination MAC address and the source MAC address in the managementpacket may be other fixed non-hardware addresses. This is not limited inthis embodiment of this application.

A destination device of the IP address assignment notification sent bythe gateway device to the interface extension device is the to-be-joinednetwork node. Therefore, the IP address assignment notification is adata packet. In an Ethernet frame obtained by performing MAC layerencapsulation on the IP address assignment notification, a targetindication field is used to indicate that a packet type of the Ethernetframe is the data packet. A source MAC address in an Ethernet frameheader encapsulated in the IP address assignment notification is a MACaddress of a virtual interface, and a destination MAC address is the MACaddress of the to-be-joined network node. Similarly, for another datapacket, for example, a service packet sent from a network node accessedthrough the first non-Ethernet interface to another network node, adestination MAC address in an Ethernet frame header of the servicepacket is a MAC address of a virtual interface, and a source MAC addressis a MAC address of the network node.

Optionally, different marks such as digits, characters, or letters maybe carried in the target indication field, to distinguish between packettypes of Ethernet frames. For example, when the target indication fieldcarries a first value, it indicates that a packet type of an Ethernetframe is a management packet. When the target indication field carries asecond value, it indicates that a packet type of an Ethernet frame is adata packet.

For example, FIG. 4 is a schematic diagram depicting a structure of anEthernet frame according to this embodiment of this application. Asshown in FIG. 4, the Ethernet frame includes an Ethernet frame headerand a payload. For a structure of the Ethernet frame, refer to theEthernet frame format defined in the Institute of Electrical andElectronics Engineers (IEEE) 802.1Q. The Ethernet frame header includesa destination MAC field, a source MAC field, a tag protocol identifier(TPID) field, a TCI field, and an Ethernet type (eth type) field. Thedestination MAC field has a length of 6 bytes, the source MAC field hasa length of 6 bytes, the TPID field has a length of 2 bytes, the TCIfield has a length of 2 bytes, and the Ethernet type field has a lengthof 2 bytes. The payload includes an IP packet header, a transport layerprotocol field, and a data field. The target indication field may be theTPID field.

Optionally, when a packet type of an Ethernet frame is a managementpacket, the TCI field is used to indicate a packet length of theEthernet frame; and the Ethernet type field may be used to indicate aservice type of the Ethernet frame, for example, used to indicate thatthe Ethernet frame is a registration message (including an interfacemessage, an interface creation success notification, and an interfaceparameter), an authentication message (including a network accessnotification), or the like. When a packet type of an Ethernet frame is adata packet, the TCI field is used to indicate a priority of theEthernet frame; and the Ethernet type field is used to indicate anEthernet type, including a used IP protocol. For example, when theEthernet type field is 0x86DD, it indicates that the IPv6 protocol isused. When the Ethernet type field is 0x8100, it indicates that the IPv4protocol is used. In this embodiment of this application, both theregistration message and the authentication message may be carried inthe data field of the payload of the Ethernet frame for sending afterbeing TLV-encoded.

As described above, there may be a plurality of non-Ethernet interfaceson the interface extension device. For example, the interface extensiondevice further includes the second non-Ethernet interface. The secondvirtual interface corresponding to the second non-Ethernet interface isfurther created on the target Ethernet interface. In other words, whenthe gateway device includes a plurality of virtual interfaces, thetarget indication field in the Ethernet frame is further used toindicate a virtual interface of the gateway device for transmission ofthe Ethernet frame. Optionally, when the MAC address of the firstnon-Ethernet interface and the MAC address of the second non-Ethernetinterface are the same, the virtual interface used to transmit theEthernet frame needs to be indicated by using the target indicationfield, so that the gateway device can forward the Ethernet frame througha correct virtual interface.

In a first possible implementation, the target indication field includesa first indication field and a second indication field. The firstindication field is used to indicate the packet type of the Ethernetframe. The second indication field is used to indicate a virtualinterface of the gateway device for transmission of the Ethernet frame.For example, the first byte of the TPID field may be used as the firstindication field, and the second byte of the TPID field may be used asthe second indication field. Alternatively, the TPID field may be usedas the first indication field, and a new field added to the Ethernetframe is used as the second indication field. This is not limited inthis embodiment of this application.

In a second possible implementation, the target indication field may beone field, and both the packet type of the Ethernet frame and thevirtual interface for transmission of the Ethernet frame may beindicated by different content carried in the target indication field.For example, it is assumed that the gateway device includes two virtualinterfaces: the first virtual interface and the second virtualinterface. When the target indication field carries a first value, itindicates that the packet type of the Ethernet frame is the managementpacket, and the first virtual interface is used for transmission of theEthernet frame. When the target indication field carries a second value,it indicates that the packet type of the Ethernet frame is the datapacket, and the second virtual interface is used for transmission of theEthernet frame. When the target indication field carries a third value,it indicates that the packet type of the Ethernet frame is themanagement packet, and the second virtual interface is used fortransmission of the Ethernet frame. When the target indication fieldcarries a fourth value, it indicates that the packet type of theEthernet frame is the data packet, and the second virtual interface isused for transmission of the Ethernet frame.

A sequence of the steps of the interface extension method provided inthis embodiment of this application may be properly adjusted. The stepsmay also be correspondingly added or removed as required. Any variationmethod readily figured out by a person skilled in the art within thetechnical scope disclosed in this application shall fall within theprotection scope of this application. Therefore, details are notdescribed herein.

In conclusion, in the interface extension method provided in thisembodiment of this application, the target Ethernet interface of thegateway device is connected to the Ethernet interface of the interfaceextension device, so that the gateway device creates, on the targetEthernet interface, the first virtual interface corresponding to thefirst non-Ethernet interface of the interface extension device. Becausethe MAC address of the first virtual interface is the same as the MACaddress of the first non-Ethernet interface, data arriving at the firstnon-Ethernet interface on the interface extension device can arrive atthe first virtual interface of the gateway device. In other words, thefirst non-Ethernet interface on the interface extension device isequivalent to a remote physical interface of the first virtual interfaceon the gateway device. This implements interface extension of thegateway device, so that the gateway device can be connected to theperception layer network through the non-Ethernet interface on theinterface extension device. In other words, the gateway device can beconnected to different perception layer networks through the interfaceextension device provided that the gateway device includes an Ethernetinterface. The gateway device has good generality. In addition, theinterface extension device implements layer-2 protocol conversionbetween Ethernet and the perception layer network, and the gatewaydevice implements the layer-3 forwarding function, so that heterogeneousperception layer networks can communicate with each other. In addition,the gateway device and the interface extension device may be separatelydeployed, so that the interface extension device can be remotelydeployed. Therefore, flexibility of device deployment is high.

FIG. 5 is a schematic diagram depicting a structure of an interfaceextension apparatus according to an embodiment of this application. Theapparatus may be used in the gateway device 101 in the interfaceextension system shown in FIG. 1. As shown in FIG. 5, the apparatus 50includes: a first receiving module 501, configured to receive interfaceinformation sent by an interface extension device, where an Ethernetinterface of the interface extension device is connected to a targetEthernet interface of the gateway device, and the interface informationincludes an interface type and a MAC address of a first non-Ethernetinterface of the interface extension device; a creation module 502,configured to create a first virtual interface on the target Ethernetinterface based on the interface information, where the first virtualinterface corresponds to the first non-Ethernet interface, and aninterface type of the first virtual interface is an Ethernet interface;and a first sending module 503, configured to send an interface creationsuccess notification to the interface extension device.

Optionally, that the first virtual interface corresponds to the firstnon-Ethernet interface includes: A MAC address of the first virtualinterface is the same as the MAC address of the first non-Ethernetinterface.

The interface information may further include an interface type and aMAC address of a second non-Ethernet interface of the interfaceextension device. The creation module 502 is further configured tocreate, on the target Ethernet interface, a second virtual interfacecorresponding to the second non-Ethernet interface. An interface type ofthe second virtual interface is an Ethernet interface.

Optionally, as shown in FIG. 6, the apparatus 50 further includes: anassignment module 504, configured to assign an IP address to the firstvirtual interface; and an entry updating module 505, configured to add arouting entry corresponding to the first virtual interface to a routingtable of the gateway device.

Optionally, as shown in FIG. 7, the apparatus 50 further includes: asecond receiving module 506, configured to receive a network accessnotification sent by the interface extension device, where the networkaccess notification includes an identifier of a to-be-joined networknode, and the to-be-joined network node is a network node that completeslayer-2 networking with the interface extension device through the firstnon-Ethernet interface; and a second sending module 507, configured tosend an IP address assignment notification to the to-be-joined networknode through the interface extension device, where the IP addressassignment notification includes an IP address of the to-be-joinednetwork node, the IP address of the to-be-joined network node and the IPaddress of the first virtual interface belong to a same network segment,a source MAC address of the IP address assignment notification is a MACaddress of the first virtual interface, a destination MAC address of theIP address assignment notification is a MAC address of the to-be-joinednetwork node, and the MAC address of the first virtual interface is thesame as the MAC address of the first non-Ethernet interface.

Optionally, the identifier of the to-be-joined network node includes theMAC address of the to-be-joined network node. The entry updating module505 in the apparatus 50 is further configured to add a neighbor entrycorresponding to the to-be-joined network node to a neighbor table ofthe gateway device.

Optionally, an Ethernet frame is used for information transmissionbetween the gateway device and the interface extension device. TheEthernet frame includes a target indication field. The target indicationfield is used to indicate a packet type of the Ethernet frame. Thepacket type includes a management packet or a data packet. A destinationdevice of the management packet is the gateway device or the interfaceextension device. A destination device of the data packet is neither thegateway device nor the interface extension device.

Optionally, the target indication field is further used to indicate avirtual interface of the gateway device for transmission of the Ethernetframe.

Optionally, the target indication field includes a first indicationfield and a second indication field. The first indication field is usedto indicate the packet type of the Ethernet frame. The second indicationfield is used to indicate a virtual interface of the gateway device fortransmission of the Ethernet frame.

Optionally, the target indication field is a tag protocol identifierfield.

Optionally, the Ethernet frame further includes a TCI field. When thepacket type of the Ethernet frame is the management packet, the TCIfield is used to indicate a packet length of the Ethernet frame. Whenthe packet type of the Ethernet frame is the data packet, the TCI fieldis used to indicate a priority of the Ethernet frame.

Optionally, as shown in FIG. 8, the apparatus 50 further includes: athird sending module 508, configured to send an interface parameter tothe interface extension device, where the interface parameter includes achannel and/or transmit power of the first non-Ethernet interface.

Optionally, the apparatus 50 further includes an enabling/disablingcontrol module, configured to control whether the apparatus 50 enablesthe interface extension method provided in the embodiments of thisapplication. When enabling is performed, the apparatus 50 performs theinterface extension method shown in FIG. 3, that is, performs interfaceextension on the target Ethernet interface of the gateway device. Whendisabling is performed, the apparatus 50 does not perform the interfaceextension method shown in FIG. 3. In this case, the target Ethernetinterface of the gateway device is used for common layer-2 and layer-3communication.

For details not provided herein, refer to the detailed description inthe interface extension method shown in FIG. 3.

In conclusion, in the interface extension apparatus provided in thisembodiment of this application, the target Ethernet interface of thegateway device is connected to the Ethernet interface of the interfaceextension device, and the gateway device creates, on the target Ethernetinterface, the first virtual interface corresponding to the firstnon-Ethernet interface of the interface extension device through acreation module. Because the MAC address of the first virtual interfaceis the same as the MAC address of the first non-Ethernet interface, dataarriving at the first non-Ethernet interface on the interface extensiondevice can arrive at the first virtual interface of the gateway device.In other words, the first non-Ethernet interface on the interfaceextension device is equivalent to a remote physical interface of thefirst virtual interface on the gateway device. This implements interfaceextension of the gateway device, so that the gateway device can beconnected to the perception layer network through the non-Ethernetinterface on the interface extension device. In other words, the gatewaydevice can be connected to different perception layer networks throughthe interface extension device provided that the gateway device includesan Ethernet interface. The gateway device has good generality.

FIG. 9 is a schematic diagram depicting a structure of an interfaceextension apparatus according to another embodiment of this application.The apparatus may be used in the interface extension device 102 in theinterface extension system shown in FIG. 1. As shown in FIG. 9, theapparatus 90 includes: a first sending module 901, configured to sendinterface information to a gateway device, where an Ethernet interfaceof the interface extension device is connected to a target Ethernetinterface of the gateway device, the interface information includes aninterface type and a MAC address of a first non-Ethernet interface ofthe interface extension device, so that the gateway device creates, onthe target Ethernet interface based on the interface information, afirst virtual interface corresponding to the first non-Ethernetinterface, and an interface type of the first virtual interface is anEthernet interface; and a receiving module 902, configured to receive aninterface creation success notification sent by the gateway device,where the interface creation success notification is used to indicatethe interface extension apparatus that the gateway device has completedcreation of a virtual interface corresponding to a non-Ethernetinterface in the interface information.

The interface creation success notification is sent by the gatewaydevice after the gateway device creates, on the target Ethernetinterface based on the interface information, the virtual interfacecorresponding to the non-Ethernet interface.

Optionally, that the first virtual interface corresponds to the firstnon-Ethernet interface includes: A MAC address of the first virtualinterface is the same as the MAC address of the first non-Ethernetinterface.

Optionally, the interface information further includes an interface typeand a MAC address of a second non-Ethernet interface of the interfaceextension device, so that the gateway device creates, on the targetEthernet interface, a second virtual interface corresponding to thesecond non-Ethernet interface. An interface type of the second virtualinterface is an Ethernet interface.

Optionally, as shown in FIG. 10, the apparatus 90 further includes: asecond sending module 903, configured to send a network accessnotification to the gateway device after the interface extension devicecompletes layer-2 networking with a to-be-joined network node throughthe first non-Ethernet interface, where the network access notificationincludes an identifier of the to-be-joined network node; and aforwarding module 904, configured to: receive an IP address assignmentnotification that is sent by the gateway device to the to-be-joinednetwork node, convert a frame type of the IP address assignmentnotification into a target frame type, send an IP address assignmentnotification whose frame type is the target frame type to theto-be-joined network node through the first non-Ethernet interface,where the IP address assignment notification includes an IP address ofthe to-be-joined network node, and the target frame type is a frame typesupported by a network to which the to-be-joined network node belongs.The IP address of the to-be-joined network node and an IP address of thefirst virtual interface belong to a same network segment. A source MACaddress of the IP address assignment notification is a MAC address ofthe first virtual interface. A destination MAC address of the IP addressassignment notification is a MAC address of the to-be-joined networknode. The MAC address of the first virtual interface is the same as theMAC address of the first non-Ethernet interface.

Optionally, an Ethernet frame is used for information transmissionbetween the gateway device and the interface extension device. TheEthernet frame includes a target indication field. The target indicationfield is used to indicate a packet type of the Ethernet frame. Thepacket type includes a management packet or a data packet. A destinationdevice of the management packet is the gateway device or the interfaceextension device. A destination device of the data packet is neither thegateway device nor the interface extension device.

Optionally, the target indication field is further used to indicate avirtual interface of the gateway device for transmission of the Ethernetframe.

Optionally, the target indication field includes a first indicationfield and a second indication field. The first indication field is usedto indicate the packet type of the Ethernet frame. The second indicationfield is used to indicate a virtual interface of the gateway device fortransmission of the Ethernet frame.

Optionally, the target indication field is a tag protocol identifierfield.

Optionally, the Ethernet frame further includes a tag controlinformation TCI field. When the packet type of the Ethernet frame is themanagement packet, the TCI field is used to indicate a packet length ofthe Ethernet frame. When the packet type of the Ethernet frame is thedata packet, the TCI field is used to indicate a priority of theEthernet frame.

For details not provided herein, refer to the detailed description inthe interface extension method shown in FIG. 3.

In conclusion, in the interface extension apparatus provided in thisembodiment of this application, the interface extension device sends theinterface information to the gateway device through the first sendingmodule. The target Ethernet interface of the gateway device is connectedto the Ethernet interface of the interface extension device, and thegateway device creates, on the target Ethernet interface, the firstvirtual interface corresponding to the first non-Ethernet interface ofthe interface extension device through a creation module. Because theMAC address of the first virtual interface is the same as the MACaddress of the first non-Ethernet interface, data arriving at the firstnon-Ethernet interface on the interface extension device can arrive atthe first virtual interface of the gateway device. In other words, thefirst non-Ethernet interface on the interface extension device isequivalent to a remote physical interface of the first virtual interfaceon the gateway device. This implements interface extension of thegateway device, so that the gateway device can be connected to theperception layer network through the non-Ethernet interface on theinterface extension device. In other words, the gateway device can beconnected to different perception layer networks through the interfaceextension device provided that the gateway device includes an Ethernetinterface. The gateway device has good generality.

FIG. 11 is a block diagram of a gateway device according to anembodiment of this application. As shown in FIG. 11, the gateway device110 includes a processor 1101, a memory 1102, a communication bus 1103,and a communication interface 1104.

The processor 1101, the memory 1102, and the communication interface1104 are connected to each other through the communication bus 1103. Thecommunication bus 1103 may be a Peripheral Component Interconnect (PCI)bus, an extended industry standard architecture (EISA) bus, or the like.The communication bus may be classified into an address bus, a data bus,a control bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 11, but this does not meanthat there is only one bus or only one type of bus.

The processor 1101 may be a central processing unit (CPU), a networkprocessor (NP), or a combination of a CPU and an NP.

The processor 1101 may further include a hardware chip. The hardwarechip may be an application-specific integrated circuit (ASIC), aprogrammable logic device (PLD), or a combination thereof. The PLD maybe a complex programmable logic device (CPLD), a field-programmable gatearray (FPGA), generic array logic (GAL), or any combination thereof.

Optionally, the memory 1102 may be configured to store a computerprogram, where the computer program includes program instructions. Theprocessor 1101 is configured to invoke a computer program to implementsteps performed by the gateway device in the interface extension methodshown in FIG. 3.

The memory 1102 may include a volatile memory, for example, arandom-access memory (RAM). The memory may alternatively include anon-volatile memory, for example, a flash memory, a hard disk drive(HDD), or a solid-state drive (SSD). The memory 1102 may further includea combination of the foregoing types of memories.

There may be a plurality of communication interfaces 1104. Thecommunication interface 1104 is configured to communicate with anotherdevice, for example, communicate with an interface extension device. Thecommunication interface 1104 includes a wired communication interface,and the wired communication interface includes an Ethernet interface.The Ethernet interface may be an optical interface, an electricalinterface, or a combination thereof. The communication interface 1104may further include a wireless communication interface. The wirelesscommunication interface may be a wireless local area network (WLAN)interface, an RF interface, a ZIGBEE interface, a cellular networkcommunication interface, or a combination thereof.

FIG. 12 is a block diagram of an interface extension device according toan embodiment of this application. As shown in FIG. 12, the interfaceextension device 120 includes a processor 1201, a memory 1202, acommunication bus 1203, and a communication interface 1204.

The processor 1201, the memory 1202, and the communication interface1204 are connected to each other through the communication bus 1203. Thecommunication bus 1203 may be a PCI bus, an EISA bus, or the like. Thecommunication bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent in FIG. 12, but this does not mean that thereis only one bus or only one type of bus.

The processor 1101 may be a CPU, an NP, or a combination of a CPU and anNP.

The processor 1201 may further include a hardware chip. The hardwarechip may be an ASIC, a PLD, or a combination thereof. The PLD may be aCPLD, an FPGA, a GAL, or any combination thereof.

Optionally, the memory 1202 may be configured to store a computerprogram, where the computer program includes program instructions. Theprocessor 1201 executes the computer program stored in the memory 1202,to implement steps performed by the interface extension device in theinterface extension method shown in FIG. 3.

The memory 1202 may include a volatile memory such as a RAM, anon-volatile memory such as a flash memory, an HDD, or an SSD, or acombination of the foregoing types of memories.

There may be a plurality of communication interfaces 1204. Thecommunication interface 1204 is configured to communicate with anotherdevice, for example, communicate with a gateway device. Thecommunication interface 1204 includes a wired communication interface,and the wired communication interface includes an Ethernet interface.The Ethernet interface may be an optical interface, an electricalinterface, or a combination thereof. The wired communication interfacemay further include a PLC interface, an OT interface, and the like. Thecommunication interface 1204 may further include a wirelesscommunication interface. The wireless communication interface may be aWLAN interface, an RF interface, a ZIGBEE interface, a cellular networkcommunication interface, or a combination thereof.

An embodiment of this application further provides an interfaceextension system. The interface extension system includes a gatewaydevice and an interface extension device. An Ethernet interface of thegateway device is connected to an Ethernet interface of the interfaceextension device.

The gateway device includes the interface extension apparatus shown inany one of FIG. 5 to FIG. 8, and the interface extension device includesthe interface extension apparatus shown in FIG. 9 or FIG. 10.

An embodiment of this application further provides a computer storagemedium. The computer storage medium stores instructions. When theinstructions are executed by a processor of a gateway device, stepsperformed by the gateway device in the interface extension method shownin FIG. 3 are implemented.

An embodiment of this application further provides another computerstorage medium. The computer storage medium stores instructions. Whenthe instructions are executed by a processor of an interface extensiondevice, steps performed by the interface extension device in theinterface extension method shown in FIG. 3 are implemented.

A person of ordinary skill in the art may understand that all or some ofthe steps in the embodiments may be implemented by hardware or a programinstructing related hardware. The program may be stored in acomputer-readable storage medium. The storage medium may be a read-onlymemory, a magnetic disk, an optical disc, or the like.

In the embodiments of this application, the terms “first”, “second”, and“third” are merely used for description purposes, but cannot beunderstood as an indication or implication of relative importance. Theterm “at least one” means one or more, and the term “a plurality” meanstwo or more, unless expressly limited otherwise.

The term “and/or” in this application describes only an associationrelationship for describing associated objects and indicates that threerelationships may exist. For example, A and/or B may indicate thefollowing three cases: Only A exists, both A and B exist, and only Bexists. In addition, the character “/” in this specification generallyindicates an “or” relationship between the associated objects.

The foregoing descriptions are merely optional embodiments of thisapplication, but are not intended to limit this application. Anymodification, equivalent replacement, or improvement made withoutdeparting from the spirit and principle of this application should fallwithin the protection scope of this application.

What is claimed is:
 1. An interface extension method implemented by agateway device, wherein the interface extension method comprises:receiving interface information from an interface extension device,wherein the interface information comprises a first interface type and afirst media access control (MAC) address of a first non-Ethernetinterface of the interface extension device; creating, based on theinterface information, a first virtual interface on a target Ethernetinterface of the gateway device, wherein the first virtual interfacecorresponds to the first non-Ethernet interface, and wherein a secondinterface type of the first virtual interface is a second Ethernetinterface; and sending an interface creation success notification to theinterface extension device.
 2. The interface extension method of claim1, wherein the interface information further comprises a third interfacetype and a second MAC address of a second non-Ethernet interface of theinterface extension device, wherein the interface extension methodfurther comprises creating, on the target Ethernet interface, a secondvirtual interface corresponding to the second non-Ethernet interface,and wherein a fourth interface type of the second virtual interface is athird Ethernet interface.
 3. The interface extension method of claim 1,wherein after creating the first virtual interface, the interfaceextension method further comprises: assigning a first Internet Protocol(IP) address to the first virtual interface; and adding a routing entrycorresponding to the first virtual interface to a routing table of thegateway device.
 4. The interface extension method of claim 3, whereinafter sending the interface creation success notification, the interfaceextension method further comprises: receiving a network accessnotification from the interface extension device, wherein the networkaccess notification comprises an identifier of a to-be-joined networknode; and sending an IP address assignment notification to theto-be-joined network node through the interface extension device,wherein the IP address assignment notification comprises a second IPaddress of the to-be-joined network node, wherein the second IP addressand the first IP address belong to a same network segment, wherein asource MAC address of the IP address assignment notification is a secondMAC address of the first virtual interface, wherein a destination MACaddress of the IP address assignment notification is a third MAC addressof the to-be-joined network node, and wherein the second MAC address isthe same as the third MAC address.
 5. The interface extension method ofclaim 4, wherein the identifier comprises the third MAC address, andwherein after sending the IP address assignment notification, theinterface extension method further comprises adding a neighbor entrycorresponding to the to-be-joined network node to a neighbor table ofthe gateway device.
 6. The interface extension method of claim 1,further comprising transmitting information between the gateway deviceand the interface extension device using an Ethernet frame, wherein theEthernet frame comprises a target indication field, wherein the targetindication field indicates a packet type of the Ethernet frame, whereinthe packet type comprises a management packet or a data packet, whereina first destination device of the management packet is the gatewaydevice or the interface extension device, and wherein a seconddestination device of the data packet is neither the gateway device northe interface extension device.
 7. The interface extension method ofclaim 6, wherein the target indication field further indicates a thirdvirtual interface of the gateway device for transmission of the Ethernetframe.
 8. An interface extension method implemented by an interfaceextension device, wherein the interface extension method comprises:sending interface information to a gateway device, wherein the interfaceinformation comprises a first interface type and a first media accesscontrol (MAC) address of a first non-Ethernet interface of the interfaceextension device, wherein the interface information instructs thegateway device to create, on a target Ethernet interface of the gatewaydevice and based on the interface information, a first virtual interfacecorresponding to the first non-Ethernet interface, and wherein a secondinterface type of the first virtual interface is a second Ethernetinterface; and receiving an interface creation success notification fromthe gateway device, wherein the interface creation success notificationindicates that the gateway device has completed creation of the firstvirtual interface.
 9. The interface extension method of claim 8, whereinthe interface information further comprises a third interface type and aMAC address of a second non-Ethernet interface of the interfaceextension device, wherein the interface information further instructsthe gateway device to create, on the target Ethernet interface, a secondvirtual interface corresponding to the second non-Ethernet interface,and wherein a third interface type of the second virtual interface is athird Ethernet interface.
 10. The interface extension method of claim 8,wherein after receiving the interface creation success notification, theinterface extension method further comprises: sending a network accessnotification to the gateway device after the interface extension devicecompletes layer-2 networking with a to-be-joined network node throughthe first non-Ethernet interface, wherein the network accessnotification comprises an identifier of the to-be-joined network node;and receiving a first Internet Protocol (IP) address assignmentnotification; converting a frame type of the first IP address assignmentnotification into a target frame type; and sending a second IP addressassignment notification of the target frame type to the to-be-joinednetwork node through the first non-Ethernet interface, wherein thesecond IP address assignment notification comprises a first IP addressof the to-be-joined network node, wherein the target frame type issupported by a network to which the to-be-joined network node belongs,wherein the first IP address and a second IP address of the firstvirtual interface belong to a same network segment, wherein a source MACaddress of the second IP address assignment notification is a second MACaddress of the first virtual interface, wherein a destination MACaddress of the second IP address assignment notification is a third MACaddress of the to-be-joined network node, and wherein the second MACaddress is the same as the third MAC address.
 11. The interfaceextension method of claim 8, further comprising transmitting informationbetween the interface extension device and the gateway device using anEthernet frame, wherein the Ethernet frame comprises a target indicationfield, wherein the target indication field indicates a packet type ofthe Ethernet frame, wherein the packet type comprises a managementpacket or a data packet, wherein a first destination device of themanagement packet is the gateway device or the interface extensiondevice, and wherein a second destination device of the data packet isneither the gateway device nor the interface extension device.
 12. Theinterface extension method of claim 11, wherein the target indicationfield further indicates a second virtual interface of the gateway devicefor transmission of the Ethernet frame.
 13. The interface extensionmethod of claim 11, wherein the target indication field comprises afirst indication field and a second indication field, wherein the firstindication field indicates the packet type, and wherein the secondindication field indicates a second virtual interface of the gatewaydevice for transmission of the Ethernet frame.
 14. An interfaceextension apparatus implemented in a gateway device, wherein theinterface extension apparatus comprises: a memory configured to storeinstructions; and a processor coupled to the memory and configured toexecute the instructions to cause the interface extension apparatus to:receive interface information from an interface extension device,wherein the gateway device comprises a target Ethernet interface that iscoupled to a first Ethernet interface of the interface extension device,and wherein the interface information comprises a first interface typeand a first media access control (MAC) address of a first non-Ethernetinterface of the interface extension device; create, based on theinterface information, a first virtual interface on the target Ethernetinterface, wherein the first virtual interface corresponds to the firstnon-Ethernet interface, and wherein a second interface type of the firstvirtual interface is a second Ethernet interface; and send an interfacecreation success notification to the interface extension device.
 15. Theinterface extension apparatus of claim 14, wherein the interfaceinformation further comprises a third interface type and a second MACaddress of a second non-Ethernet interface of the interface extensiondevice, wherein the instructions further cause the interface extensionapparatus to create, on the target Ethernet interface, a second virtualinterface corresponding to the second non-Ethernet interface, andwherein a fourth interface type of the second virtual interface is athird Ethernet interface.
 16. The interface extension apparatus of claim14, wherein the instructions further cause the interface extensionapparatus to: assign a first Internet Protocol (IP) address to the firstvirtual interface; and add a routing entry corresponding to the firstvirtual interface to a routing table of the gateway device.
 17. Theinterface extension apparatus of claim 16, wherein the instructionsfurther cause the interface extension apparatus to: receive a networkaccess notification from the interface extension device, wherein thenetwork access notification comprises an identifier of a to-be-joinednetwork node, and wherein the to-be-joined network node completeslayer-2 networking with the interface extension device through the firstnon-Ethernet interface; and send an IP address assignment notificationto the to-be-joined network node through the interface extension device,wherein the IP address assignment notification comprises a second IPaddress of the to-be-joined network node, wherein the second IP addressand the first IP address belong to a same network segment, wherein asource MAC address of the IP address assignment notification is a secondMAC address of the first virtual interface, wherein a destination MACaddress of the IP address assignment notification is a third MAC addressof the to-be-joined network node, and wherein the second MAC address isthe same as the third MAC address.
 18. The interface extension apparatusof claim 17, wherein the identifier comprises the second MAC address,and wherein the instructions further cause the interface extensionapparatus to add a neighbor entry corresponding to the to-be-joinednetwork node to a neighbor table of the gateway device.
 19. Theinterface extension apparatus of claim 14, wherein the instructionsfurther cause the interface extension apparatus to transmit informationtransmission between the gateway device and the interface extensiondevice using an Ethernet frame, wherein the Ethernet frame comprises atarget indication field, wherein the target indication field indicates apacket type of the Ethernet frame, wherein the packet type comprises amanagement packet or a data packet, wherein a first destination deviceof the management packet is the gateway device or the interfaceextension device, and wherein a second destination device of the datapacket is neither the gateway device nor the interface extension device.20. The interface extension apparatus of claim 19, wherein the targetindication field further indicates a third virtual interface of thegateway device for transmission of the Ethernet frame.